//
//  MyHelperCollectionViewCell.m
//  YYZB
//
//  Created by CCPG_iOS on 2017/2/16.
//
//

#import "MyHelperCollectionViewCell.h"
#import "ThemeColor.h"
#import "UIImageView+OnlineImage.h"
@implementation MyHelperCollectionViewCell

- (id)initWithFrame:(CGRect)frame{
    if (self = [super initWithFrame:frame]) {
        self.imageView888 = [[UIImageView alloc]initWithFrame:CGRectMake(2.5, 5, self.frame.size.width - 20, self.frame.size.width - 20)];
        
        
        self.nameLabel = [[UILabel alloc]initWithFrame:CGRectMake(0, self.frame.size.width - 20 + 5, self.frame.size.width - 10, 15)];
        self.nameLabel.textAlignment = NSTextAlignmentCenter;
        self.nameLabel.font = [UIFont systemFontOfSize:14];
        self.priceLabel = [[UILabel alloc]initWithFrame:CGRectMake(0, self.frame.size.width  , self.frame.size.width - 10, 50)];
        self.priceLabel.textAlignment = NSTextAlignmentCenter;
        self.priceLabel.font = [UIFont systemFontOfSize:14];
        self.priceLabel.numberOfLines = 0;
        [self addSubview:self.imageView888];
        [self addSubview:self.nameLabel];
        [self addSubview:self.priceLabel];
        self.nameLabel.textColor = [UIColor darkGrayColor];
        self.priceLabel.textColor = [ThemeColor orangeColor];
    }
    return self;
}



-(void)fillData:(Project *)model{

    [self.imageView888 setOnlineImage:model.imagePath];
    self.nameLabel.text = model.name;
    NSString *format = model.isGroupBy == 0 ? @"¥%@" : @"%@";
    if ([model.paymentType integerValue] == 2) {
        format = [format stringByAppendingString:model.unitExtend];
    }
    self.priceLabel.text = [NSString stringWithFormat:format, model.price];
    CGSize size = [self.priceLabel.text sizeWithFont:Font(14) maxSize:CGSizeMake(self.frame.size.width - 10, 50)];
    self.priceLabel.frame = CGRectMake(0, self.frame.size.width  , self.frame.size.width - 10, size.height+10);



}

@end
